package com.HW;

import java.util.*;

/**
 * @ClassName : TAIPana
 * @Author : kele
 * @Date: 2023/10/29 17:00
 * @Description :
 */
public class TAIPana {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int m = in.nextInt();

        int[][] arr = new int[m][5];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < 5; j++) {
                arr[i][j] = in.nextInt();
            }
        }

//        int[][] arr = new int[][]{{1, 0, 0, 2, 2}, {2, 6, 1, 8, 3}, {3, 3, 2, 5, 4}, {5, 5, 4, 7, 6}, {4, 0, 4, 2, 6}};
//
//        handle(5, arr);
        handle(5,arr);

    }

    public static void handle(int n, int[][] arr) {

        if(n == 0) {
            System.out.println();
            return;
        }

        int r = (arr[0][3] - arr[0][1]) / 2;

        int maxY = 0;

        for (int i = 0; i < arr.length; i++) {

             maxY = Math.max(maxY, arr[i][4]);

        }
        List<Integer> rank = new ArrayList<>();

        for (int i = r; i <= maxY - r; i = i + r) {

            ArrayList<Integer[]> line = new ArrayList<>();
            for (int j = 0; j < n; j++) {
                int x = (arr[j][1] + arr[j][3]) / 2;
                int y = (arr[j][2] + arr[j][4]) / 2;

                if (y - i < r && y - i >= 0) {
                    line.add(new Integer[]{arr[j][0], x});
                }
            }

            line.sort(new Comparator<Integer[]>() {
                @Override
                public int compare(Integer[] o1, Integer[] o2) {
                    return o1[1] - o2[1];
                }
            });

            for (Integer[] integers : line) {
                rank.add(integers[0]);
            }
//            System.out.println();
        }

        StringBuilder builder = new StringBuilder();
        for (Integer integer : rank) {
            builder.append(integer).append(" ");
        }

        System.out.println(builder.substring(0, builder.length() - 1));

    }

}
